vulkan: Allow to control scaling in the blend pipeline
authorMatthias Clasen <mclasen@redhat.com>
Sat, 30 Sep 2017 02:07:30 +0000 (22:07 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 30 Sep 2017 02:12:25 +0000 (22:12 -0400)
Pass in a second rect that defines the size of the texture.
Update the sole caller to pass in the same rect, for unchanged
behavior.

gsk/gskvulkanblendpipeline.c
gsk/gskvulkanblendpipelineprivate.h
gsk/gskvulkanrenderpass.c

index 6d939ca296f98a299c0d90f3e8ca6486ed042c2c..2bcd5491fa8649773c8b7cd81875582781e6d974 100644 (file)
@@ -93,7 +93,8 @@ gsk_vulkan_blend_pipeline_count_vertex_data (GskVulkanBlendPipeline *pipeline)
 void
 gsk_vulkan_blend_pipeline_collect_vertex_data (GskVulkanBlendPipeline *pipeline,
                                                guchar                 *data,
-                                               const graphene_rect_t  *rect)
+                                               const graphene_rect_t  *rect,
+                                               const graphene_rect_t  *tex_rect)
 {
   GskVulkanBlendInstance *instance = (GskVulkanBlendInstance *) data;
 
@@ -101,10 +102,10 @@ gsk_vulkan_blend_pipeline_collect_vertex_data (GskVulkanBlendPipeline *pipeline,
   instance->rect[1] = rect->origin.y;
   instance->rect[2] = rect->size.width;
   instance->rect[3] = rect->size.height;
-  instance->tex_rect[0] = 0.0;
-  instance->tex_rect[1] = 0.0;
-  instance->tex_rect[2] = 1.0;
-  instance->tex_rect[3] = 1.0;
+  instance->tex_rect[0] = (rect->origin.x - tex_rect->origin.x)/tex_rect->size.width;
+  instance->tex_rect[1] = (rect->origin.y - tex_rect->origin.y)/tex_rect->size.height;
+  instance->tex_rect[2] = (rect->size.width + rect->origin.x - tex_rect->origin.x)/tex_rect->size.width;
+  instance->tex_rect[3] = (rect->size.height + rect->origin.y - tex_rect->origin.y)/tex_rect->size.height;
 }
 
 gsize
index eb471981b8929207a233c2b07146a17e6cf71e85..678db008a6335f6aaa4e7085ebdf17ff771ce764 100644 (file)
@@ -21,7 +21,8 @@ GskVulkanPipeline *     gsk_vulkan_blend_pipeline_new                   (GdkVulk
 gsize                   gsk_vulkan_blend_pipeline_count_vertex_data     (GskVulkanBlendPipeline         *pipeline);
 void                    gsk_vulkan_blend_pipeline_collect_vertex_data   (GskVulkanBlendPipeline         *pipeline,
                                                                          guchar                         *data,
-                                                                         const graphene_rect_t          *rect);
+                                                                         const graphene_rect_t          *rect,
+                                                                         const graphene_rect_t          *tex_rect);
 gsize                   gsk_vulkan_blend_pipeline_draw                  (GskVulkanBlendPipeline         *pipeline,
                                                                          VkCommandBuffer                 command_buffer,
                                                                          gsize                           offset,
index b222b9cd526eb7e174551b362b2f70e97a9e2dae..77f4fcd0e6fe9adfb166638925a4aab45b241192 100644 (file)
@@ -1055,6 +1055,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
             op->render.vertex_offset = offset + n_bytes;
             gsk_vulkan_blend_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_PIPELINE (op->render.pipeline),
                                                            data + n_bytes + offset,
+                                                           &op->render.node->bounds,
                                                            &op->render.node->bounds);
             n_bytes += op->render.vertex_count;
           }